//
// Created by Administrator on 2023/7/28.
//
#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
#include <algorithm>

using namespace std;

class Solution {
public:
    int mostWordsFound(vector<string> &sentences) {
        int ans = 1;
        for (auto &sentence: sentences) {
            // 统计每一个句子里面有几个空格
            int count = 0;
            for (auto &word: sentence) {
                if (word == ' ') {
                    count++;
                }
            }
            ans = max(ans, count + 1);
        }
        return ans;
    }
};

class Solution2 {
public:
    int mostWordsFound(vector<string> &sentences) {
        int res = 0;
        for (const string &sentence: sentences) {
            // 单词数 = 空格数 + 1
            int cnt = count(sentence.begin(), sentence.end(), ' ') + 1;
            res = max(res, cnt);
        }
        return res;
    }
};


int main() {
    Solution2 solution;
    vector<string> sentences{"alice and bob love leetcode", "i think so too", "this is great thanks very much"};
    cout << solution.mostWordsFound(sentences) << endl;
    return 0;
}
